<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>订单列表</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
</head>
<script type="text/javascript" src="/EasyBuy/statics/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/EasyBuy/statics/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" >
	$(document).ready(function() {
			
			
			
			
			
			
			
			
			/*gray(); 
			function gray(){
				$.getJSON("OrderServlet","opr=select",call);
			}
			var j =0;
			
			function call(result){
				for(var i=0;i<result.length;i++){
					
					$("#big").append("<div class='sd' id='c_"+i+"' style='width:100%;height:30px;background-color:#BEBFC3;text-align:center'><span>"+result[i].loginName+"<span><span>"+result[i].serialNumber+"<span><span>"+result[i].userAddress+"<span><span>"+result[i].cost+"<span></div>");	
					$.getJSON("OrderServlet","opr=list",function(data){
						$("#c_"+j).append("<table border='0' id='s_"+j+"' class='order_tab' style='width:100%;margin-top:30px;text-align:center' cellspacing='0' cellpadding='0'><tr><td>商品名称</td><td>商品图片</td><td>数量</td><td>价格</td></tr></table>");
						
						var h = "data.id_"+result[j].id; 
						for(var k=0;k<h.length;k++){
							var g = h.details;
							$("#s_"+j+"").append("<tr><td>"+g[0].name+"</td><td><img style='width:70px; height:70px' src='/EasyBuy/statics/images/"+g.fileName+"'/>'</td><td>"+g.quantity+"</td><td>"+gcost+"</td></tr>");
						}
						j=j+1;
					});
				}	
			} */
		$.getJSON("OrderServlet","opr=swz",function(data){
			var b = "";
			for(var i=0;i<data.length;i++){
				var s = data[i];
				var w = "";
				var g = 0; 		//上一个订单
				if(g == data.length-1){		//上一个订单判断 	不对你看下  最终g要比总数多1
					g = data.length;
				}else{
					g = i + 1;
				}
				if(b != data[i].orderId){		//当上一个订单id不等于当前订单id时候
					w = "<div><div class='sd' id='c_"+i+"' style='width:100%;height:30px;background-color:#BEBFC3;text-align:center'><span>"+s.loginName+"<span><span>"+s.serialNumber+"<span><span>地址<span><span>"+s.cost+"<span></div><table border='0' class='order_tab' style='width:100%;margin-top:30px;text-align:center' cellspacing='0' cellpadding='0'><tr><td>商品名称</td><td>商品图片</td><td>数量</td><td>价格</td></tr></table><tr><td>"+s.name+"</td><td><img style='width:70px; height:70px' src='/EasyBuy/statics/images/"+s.fileName+"'/>'</td><td>"+s.quantity+"</td><td>"+s.cost+"</td></tr>";
				}
				if(b == data[i].orderId && data[i].orderId != data[g].orderId){	//上一个订单等于当前订单 并且 当前订单id不于下一个订单id时
					w+="<tr><td>"+s.name+"</td><td><img style='width:70px; height:70px' src='/EasyBuy/statics/images/"+s.fileName+"'/>'</td><td>"+s.quantity+"</td><td>"+s.cost+"</td></tr></div>";
					$("#big").append(w);
				}
				if(b == data[i].orderId){
					w+="<tr><td>"+s.name+"</td><td><img style='width:70px; height:70px' src='/EasyBuy/statics/images/"+s.fileName+"'/>'</td><td>"+s.quantity+"</td><td>"+s.cost+"</td></tr>";
				}
				b = data[i].orderId;	//给g赋值为上一个订单
			}
				
		});
		
	});
</script>
  <body>
  	<%@ include file="../../common/header.jsp" %>
	<%@ include file="../../common/backendHeader.jsp" %>
	
	<c:choose>
		<c:when test="${empty applicationScope.type }">
			<% 	request.getRequestDispatcher("../../UserServlet?opr=type&href=Member_Order&href1=user").forward(request, response); %>
		</c:when>
		<c:otherwise>
			<c:if test="${applicationScope.type==1 }">
  				<%@ include file="../../common/sideMamber.jsp" %> 
			</c:if>
			<c:if test="${applicationScope.type==0 }">
				<%@ include file="../../common/sideUser.jsp" %> 
			</c:if>
		</c:otherwise>
	 </c:choose>
	
  <div class="m_right">
	  <span style="margin-left:25px;"><font size=4>订单列表</font></span>
	  <div style="width:95%;hright:300px;border:1" id="big">
		  	<table border='0' id='s_"+j+"' class='order_tab' style='width:100%;margin-top:30px;text-align:center' cellspacing='0' cellpadding='0'>
		  	<!-- 
		  	<tr>
			  	<td>商品名称</td>
			  	<td>商品图片</td>
			  	<td>数量</td>
			  	<td>价格</td>
		  	</tr>
		  	 -->
		  	</table>
	  </div>
  </div> 
  <%@ include file="../../common/footer.jsp" %>    <!--引入下边栏-->
  </body>
</html>
